package com.hfmall.entity;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hfmall.utils.ResponseState;


@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(value = {"handler"})
public class ResponseCode<T> {
    private int code; // 响应码
    private String msg; // 可选的描述信息
    private T data;// 可选，响应数据

    public ResponseCode() {

    }

    public ResponseCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseCode(T data) {
        this(ResponseState.SUCCESS, "ok");
        this.data = data;
    }

    public final static ResponseCode<Void> SUCCESS = new ResponseCode<>(ResponseState.SUCCESS, "ok");

    public final static ResponseCode<Void> FAIL = new ResponseCode<>(ResponseState.FAIL, "fail");

    public final static ResponseCode<Void> INVALIDARGS = new ResponseCode<>(ResponseState.INVALIDARGS, "invalidArgs");

    public void fali(){

    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
